<div id="content">
	<div id="top">
		<h3><%= @title %></h3>
		<%= render :partial => '/partials/help_link', :locals => {:path => {:controller => "help", :action => "items", :anchor => "add_remove_container"}} %>
	</div>
	<% @item_types = ItemType.find_all_by_is_container(false) %>
	<% form_for @item, :html => {:method => :put} do |f| %>
		<%= f.error_messages %>
		<div class="options">
			<ul class="right">
				<%= f.submit "Add Items" %>
			</ul>
		</div>
		<div id="main">
			<div id="spacing">
				<div id="info">
					<div class="left">
						<div class="table">
							<h3>Add Existing Items</h3>
							<ul>
								<% @available_items = Item.find_all_by_contained_by_id_and_destination_id_and_source_id(nil, @item.destination_id, @item.source_id) %>
								<% @available_items = @available_items.select do |i|
										@ok = !(i.item_type and i.item_type.is_container)
										if @ok
											@item.item_attributes.each do |ia|
												if ia.item_attribute_set.inherits_from_container
													if not i.item_attributes.include? ia
														@ok = false
													end
												end
											end
										end
										@ok
									end %>
								<% if @available_items.any? %>
									<div id="item-existing">
										<%= render :partial => 'contained_item_existing', :collection => @existing_items, :locals => {:prefix => "existing_items"}  %>
									</div>
									<li>
										<%= add_more_to_container "Add Another", "item-existing", "existing_items" %>
									</li>
								<% else %>
									<li>
										<h5>No Items</h5>
										<p>There are no available existing items to add</p>
									</li>
								<% end %>
							</ul>
						</div>
					</div>
					<div class="right">
						<h3>Add New Items</h3>
						<% @source_id = @item.source_id %>
						<% @client_id = @current_user.id %>
						<% @contained_types = ItemType.find_all_by_hidden_and_is_container(:false, :false) %>
						<div class="edit">
							<div class="edit-table">
								<div class="edit-row">
									<div id="item-new">
										<%= render :partial => 'contained_item_form', :collection => @new_items, :locals => {:prefix => "new_items"} %>
									</div>
								</div>
							</div>
						</div>
						<%= add_contained_item "Add Another", "item-new", "new_items" %>
					</div>
				</div>
			</div>
		</div>
	<% end %>
</div>
